package com.sea.app.common.kit;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by 31417 on 2017/4/23.
 */
public class Dates extends Date{

    protected Dates(long date) {
        super(date);
    }

    protected Dates(Date date){
        super(date.getTime());
    }

    public static Dates on(Long date){
        return new Dates(date);
    }

    public static Dates on(Date date){
        return new Dates(date);
    }
    public static Dates now(){
        return new Dates(new Date());
    }
    public static Dates on(Calendar date){
        return new Dates(date.getTime());
    }

    /**
     * 是否当前date 在 limitStart 和 limitEnd 之间
     * @param start
     * @param end
     * @return
     */
    public boolean between(Date start,Date end){
        return this.after(start)&&this.before(end);
    }

    public Calendar toCalendar(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(this);
        return cal;
    }
    public Dates addSecond(int second){
        Calendar cal = toCalendar();
        cal.add(Calendar.SECOND, second);
        return Dates.on(cal);
    }
    public Dates addDay(int day){
        Calendar cal = toCalendar();
        cal.add(Calendar.DATE, day);
        return Dates.on(cal);
    }

}
